Quiz 1

Question # 1

Q

Which query/queries will print the version of MySQL?

A)
SELECT NOW();
B)
SELECT VERSION();
C)
SHOW VARIABLES LIKE "%version%";
D)

B and C

Question # 2

Q

How can we get the current time and date in MYSQL?

A)
SELECT NOW();
B)
SELECT CURRENT_TIME();
C)
SELECT CURRENT_DATE();
D)
SELECT CURRENT_TIMESTAMP();
E)

A and D

Question # 3

Q

Imagine you have a table that consists only of country names. You are asked to write a query that randomly selects ten countries. Identify the correct query from the following?

A)
SELECT CountryName FROM Countries ORDER BY RAND() LIMIT 10;

The RAND() function generates a pseudorandom random number in the range 0 and 1 and orders the countries in that order.

B)
SELECT CountryName FROM Countries LIMIT 10; 

The Select clause automatically selects ten countries randomly.

C)

MySQL doesn’t have the capability to randomize the output. The application layer needs to randomize the results.

Question # 4

Q

Imagine you have table named Contacts and the following query is run:

DELETE FROM Contacts WHERE EXISTS (SELECT "constant");

What will be the outcome of the query?

A)

All the rows in the Contacts table are deleted

B)

None of the rows in the Contacts table are deleted

C)

The table Contacts is dropped altogether

Question # 5

Q

A developer on your team thinks the following query is equivalent of using a DELETE FROM clause to delete all the rows from a table named tbl. What do you think will be the outcome of running the below query:

DELETE tbl FROM tbl WHERE EXISTS (SELECT * FROM tbl);
A)

Yes, all the rows will be deleted.

B)

The query will result in an error because the tbl is also being referenced in the inner query and being updated at the same time.

C)

The syntax is invalid.

D)

The entire tbl will be dropped.

Foreign Keys
Quiz 2
Mark as Completed
Report an Issue